classdef HP4142B < DCSupply
    
    properties
        HPIB_address;
        
    end
    

    
    methods
        function this = AG3648A(GPIB_controller, GPIB_address, address)
            this = this@DCSupply(GPIB_controller, GPIB_address, address);
            %set HPIB_address
            fopen(this.conn);
            fprintf(this.conn,'*RST');
        end
        
        function delete(this)
            this.setOutputState('off',1);
            this.setOutputState('off',2);
            this.setVoltage(0,1);
            this.setVoltage(0,2);
            fclose(this.conn);
            delete(this.conn);
            
        
        end
            
        
        function setVoltage(this, voltage,channel)
            this.voltage = voltage;
            this.channel = channel;
            cmd = sprintf('OUTPUT %d;\"DV%d,0,%f\"',this.HPIB_address, channel,voltage);
            fprintf(this.conn,cmd);
            
        end
        
        function setCurrentLimit(this, current_limit, channel)
            this.current_limit = current_limit;
            this.channel = channel;
           
        end
        
        function setOutputState(this, output_state,channel)
             this.output_state = output_state;
             this.channel = channel;
             
             
             if this.output_state == 1
                cmd = sprintf('OUTPUT %d;\"CN%d\"',this.HPIB_address, channel);
            else
                cmd = sprintf('OUTPUT %d;\"CL%d\"',this.HPIB_address, channel);
             end
             fprintf(this.conn,cmd);
             
        end
        
        function result = measureCurrent(this, channel)
            this.channel = channel;
            
        end
        
         function result = measureVoltage(this, channel)
            this.channel = channel;
            
         end     
        
        
        
    end
            
    
end
